#@layout()

#define script()
<script>


    $(".addon-del").on("click", function () {
        ajaxGet("#(CPATH)/admin/addon/doDel?id=" + $(this).attr("data-id"))
    })

    $(".addon-unisntall").on("click", function () {
        if (confirm('确定要卸载该插件吗？卸载后该插件的所有数据将被删除，不可恢复。')) {
            ajaxGet("#(CPATH)/admin/addon/doUninstall?id=" + $(this).attr("data-id"))
        }
    })

    $(".addon-install").on("click", function () {
        ajaxGet("#(CPATH)/admin/addon/doInstall?id=" + $(this).attr("data-id"))
    })

    $(".addon-start").on("click", function () {
        ajaxGet("#(CPATH)/admin/addon/doStart?id=" + $(this).attr("data-id"))
    })

    $(".addon-stop").on("click", function () {
        ajaxGet("#(CPATH)/admin/addon/doStop?id=" + $(this).attr("data-id"))
    })

    $(".readme-browser").on("click", function () {
        var id = $(this).attr("data-id");
        var title = $(this).attr("data-title");
        layer.open({
            type: 2,
            title: '【' + title+'】详情',
            anim: 2,
            shadeClose: true,
            shade: 0.3,
            area: ['90%', '90%'],
            content: jpress.cpath + '/admin/addon/readme?id='+id,
        });
    })

    $(".changelog-browser").on("click", function () {
        var id = $(this).attr("data-id");
        var title = $(this).attr("data-title");
        layer.open({
            type: 2,
            title: '【' + title+'】更新日志',
            anim: 2,
            shadeClose: true,
            shade: 0.3,
            area: ['90%', '90%'],
            content: jpress.cpath + '/admin/addon/changelog?id='+id,
        });
    })


</script>

#end


#define content()

    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">
                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                插件管理
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 插件 / 插件管理</small>
                            </h1>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6 ">
                    <div class=" float-sm-right" style="padding-top: 15px">
                        <a href="./install" class="btn btn-primary ">
                            <i class="fas fa-plus"></i> 安装
                        </a>
                    </div>
                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>


    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 250px">名称</th>
                                <th>描述</th>
                                <th style="width: 100px">作者</th>
                                <th style="width: 100px">版本</th>
                            </tr>

                            #for(addon : addons)
                            <tr>
                                <td>
                                    <strong>
                                        <a href="#">#(addon.title ??)</a>
                                        #if(!addon.isInstall()) （未安装）
                                        #elseif(!addon.isStarted()) (未启用)
                                        #end
                                    </strong>

                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            #if(addon.isInstall())
                                            #if(addon.isStarted())
                                            <a href="javascript:;" style="color: #a00" data-id="#(addon.id)"
                                               class="addon-stop">停用</a> |
                                            #else
                                            <a href="javascript:;" style="color: #006505" data-id="#(addon.id)"
                                               class="addon-start">启用</a> |
                                            <a href="javascript:;" style="color: #a00" data-id="#(addon.id)"
                                               class="addon-unisntall">卸载</a> |
                                            <a href="#(CPATH)/admin/addon/upgrade?id=#(addon.id)" style="color: #a00"
                                               class="addon-upgrade">升级</a> |
                                            #end
                                            #else
                                            <a href="javascript:;" style="color: #a00" data-id="#(addon.id)"
                                               class="addon-del">删除</a> |
                                            <a href="javascript:;" style="color: #006505" data-id="#(addon.id)"
                                               class="addon-install">安装</a> |
                                            #end
                                            <a href="javascript:;" class="readme-browser" data-id="#(addon.id)"  data-title="#(addon.title ??)" style="color: #006505">详情</a> |
                                            <a href="javascript:;" class="changelog-browser" data-id="#(addon.id)" data-title="#(addon.title ??)"style="color: #006505">更新日志</a>
                                        </div>
                                    </div>

                                </td>
                                <td>#(addon.description ??)</td>
                                <td>#(addon.author ??)</td>
                                <td>#(addon.version ??)（#(addon.versionCode ?? 1)）</td>
                            </tr>
                            #else
                            <tr class="nodata"><td colspan="999">您未安装任何插件</td> </tr>
                            #end

                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-12">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.card -->
            </div>
    </section>

#end
